<%@ Page Language="c#" MasterPageFile="Admin.master" CodeBehind="Users.aspx.cs"
    AutoEventWireup="True" Inherits="CrossFactory.SiteNote.Admin.Users" %>

<%@ Register TagPrefix="mbdb" Namespace="MetaBuilders.WebControls" Assembly="MetaBuilders.WebControls.DefaultButtons" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<script language="javascript">
    function getUserNames() {
        var usersList = document.getElementById('<%= lstUsers.ClientID %>');
        var userNames = '';
        for(var i = 0; i < usersList.options.length; i++)
        {
            if (usersList.options[i].selected)
            {
                if (userNames != '')
                {
                    userNames += ', ';
                }
                userNames += usersList.options[i].value;
            }
        }
        return userNames;
    }
</script>
    <table>
        <tr>
            <td>
                <table cellpadding="0" cellspacing="0" border="0" width="300" style="padding-left:20px;">
                    <tr>
                        <td valign="top" style="padding-bottom:5px;">
                            <table cellpadding="0" cellspacing="0" width="300">
                                <tr>
                                    <td id="Td2">
                                        <table id="Table2" class="ms-toolbar" cellspacing="0" cellpadding="2" border="0">
                                            <tr id="Tr2">
                                                <td id="Td4">
                                                    <table id="Table3" cellspacing="0" cellpadding="2" border="0">
                                                        <tr id="Tr3">
                                                            <td id="Td5" class="ms-toolbar">
                                                                Users : 
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:TextBox ID="TextBoxSearch" runat="server" Width="300" Visible="false"></asp:TextBox>
                            <ajaxToolkit:AutoCompleteExtender 
                                runat="server" 
                                ID="AutoComplete1" 
                                TargetControlID="TextBoxSearch"
                                ServiceMethod="GetCompletionListUserName"
                                ServicePath="Webservices/AutoComplete.asmx"
                                MinimumPrefixLength="2" 
                                CompletionInterval="500"
                                EnableCaching="true"
                                CompletionSetCount="8" 
                                CompletionListCssClass="autocomplete_completionListElement" 
                                CompletionListItemCssClass="autocomplete_listItem" 
                                CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
                                >
                            </ajaxToolkit:AutoCompleteExtender>
                            <asp:ListBox ID="lstUsers" runat="server" Width="300px" CssClass="cmtext" Rows="10" SelectionMode="Multiple">
                            </asp:ListBox>
                        </td>            
                    </tr>
                    <tr>
                        <td style="padding-top: 10px" align="right">
                            <asp:Button ID="cmdCreateUser" runat="server" Text="Add new" CssClass="cmtext" onclick="cmdCreateUser_Click"></asp:Button>
                            <asp:Button ID="cmdDeleteUser" runat="server" Text="Delete" CssClass="cmtext" OnClientClick="return ConfirmAction('Are you sure you want to delete the following users: ' + getUserNames() + '?');" onclick="cmdDeleteUser_Click"></asp:Button>
                            <asp:Button ID="cmdModifyUser" runat="server" Text="View" CssClass="cmtext" onclick="cmdModifyUser_Click"></asp:Button>
                            <!--<asp:Button id="cmdBack" runat="server" Text="Back" CssClass="cmtext"></asp:Button>-->
                            <br />
                            <br />
                        </td>
                    </tr>
                </table>
            </td>
            <td style="padding-left:25px;" valign="top">
                <asp:Panel ID="userPanel" runat="server" Visible="False">
                    <table cellspacing="0" cellpadding="0" width="300px" border="0">
                        <tr>
                            <td valign="top">
                                <table cellpadding="0" cellspacing="0" width="300px" style="padding-bottom:5px;">
		                            <tr>
		                                <td id="Td1">
                                            <table id="Table1" class="ms-toolbar" cellspacing="0" cellpadding="2" border="0">
                                                <tr id="Tr1">
                                                    <td id="Td3">
                                                        <table id="Table4" cellspacing="0" cellpadding="2" border="0">
                                                            <tr id="Tr4">
	                                                            <td id="Td6" class="ms-toolbar">
	                                                                <asp:Label ID="lblAction" runat="server" ></asp:Label>
	                                                            </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>

                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table cellspacing="0" cellpadding="3" width="100%" border="0" style="font-family:Verdana,Arial;">
                                    <tr>
                                        <td class="usersGroupsAdminLabels">
                                            Name :
                                        </td>
                                        <td style="background-color:#D8E4F5">
                                            <asp:TextBox ID="txtUserName" BorderStyle="Solid" CssClass="cmtextbox" BorderWidth="1px" BorderColor="#84B2EF" runat="server" Width="200px"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="right">
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="* Invalid character(s)"
                                                ControlToValidate="txtUserName" Display="Dynamic" CssClass="cmtextvalidation" ValidationExpression="[\w\b\- ]+"></asp:RegularExpressionValidator>
                                        </td>
                                    </tr>
                                    <tr><td style="height:1px"></td></tr>
                                    <tr>
                                        <td class="usersGroupsAdminLabels">
                                            Password :
                                        </td>
                                        <td style="background-color:#D8E4F5">
                                            <asp:TextBox ID="txtUserPassword" BorderStyle="Solid" CssClass="cmtextbox" BorderWidth="1px" BorderColor="#84B2EF" runat="server" Width="200px"
                                                TextMode="Password"></asp:TextBox>
                                                
                                        </td>
                                    </tr>
                                    <tr><td style="height:5px"></td></tr>
                                    <tr>
                                        <td class="usersGroupsAdminLabels">
                                            Email :
                                        </td>
                                        <td style="background-color:#D8E4F5">
                                            <asp:TextBox ID="txtUserEmail" runat="server" CssClass="cmtextbox" BorderStyle="Solid" BorderWidth="1px"  BorderColor="#84B2EF" Width="200px"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-top:10px" align="right">
                                <asp:Button ID="cmdInsertUser" runat="server" CssClass="cmtext" Text="Save" onclick="cmdInsertUser_Click"></asp:Button>
                                <asp:Button ID="cmdUpdateUser" runat="server" CssClass="cmtext" Text="Update" onclick="cmdUpdateUser_Click"></asp:Button>
                                <asp:Button ID="cmdCancel" runat="server" CssClass="cmtext" Text="Cancel" onclick="cmdCancel_Click"></asp:Button>
                                <mbdb:DefaultButtons ID="DefaultButtons1" runat="server">
                                    <mbdb:DefaultButtonSetting Parent="txtUserName" Button="cmdInsertUser" />
                                    <mbdb:DefaultButtonSetting Parent="txtUserPassword" Button="cmdInsertUser" />
                                    <mbdb:DefaultButtonSetting Parent="txtUserEmail" Button="cmdInsertUser" />
                                </mbdb:DefaultButtons>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-top:10px;"><asp:Label ID="lblError" runat="server" Visible="False" CssClass="cmtextvalidation"></asp:Label></td>
                        </tr>
                    </table>
                </asp:Panel> 
            </td>
        </tr>
    </table>
</asp:Content>
